package com.zansc.longd.service.impl.s;

import com.zansc.longd.domain.entity.s.Area;
import com.zansc.longd.domain.mapper.s.AreaMapper;
import com.zansc.longd.model.base.in.AreaIn;
import com.zansc.longd.service.s.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Service
public class AreaServiceImpl implements AreaService {
    
    @Autowired
    private AreaMapper areaMapper;
    
    @Override
    public int add(AreaIn areaIn) {
        Area area = new Area();
        area.setAreaname(areaIn.getAreaname());
        area.setAreaRemark(areaIn.getAreaRemark());
        area.setCreateTime(LocalDateTime.now());
        area.setStatus(0);
        int insert = areaMapper.insert(area);
        return insert;
    }
    
    @Override
    public List<Area> findAll() {
        List<Area> areas = areaMapper.selectAll();
        return areas;
    }
    
    @Override
    public List<AreaIn> findAll1111() {
        List<AreaIn> areas = areaMapper.findAll1111();
        //List<AreaIn> areaIns = new ArrayList<>();
        //for (Area aaaa : areas) {
        //    areaIns.add(new AreaIn(aaaa.getAreaname(), aaaa.getArea_remark()));
        //}
        return areas;
    }
}
